package com.huawei.hotel.service.impl;


import com.huawei.hotel.dao.UserDao;
import com.huawei.hotel.service.UserService;
import com.huawei.hotel.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 18902
 * @date 2020/10/19 22:27
 * @desc 用户Service接口实现类
 */
@Service("userService")
@Transactional
public class UserServiceImpl implements UserService {
    //注入UserDao
    @Autowired(required=true)
    private UserDao userDao;
    //通过账户和密码查询用户
    @Override
    public User findUser(String useracount, String password) {
        User user=this.userDao.findUser(useracount,password);
        return user;
    }
    @Override
    public int register(User user) {
        return userDao.register (user);

    }


//    //用户注册
//    @Override
//    public int register(String useracount, String password, String userrole, String userpower, String username, String age, String phone,String address, String city) {
//        return userDao.register (useracount,password,userrole,userpower,username,age,phone,address,city);
//    }


    /**
     * 通过userid更新用户信息
     * @param user
     * @return
     */
    @Override
    public int updateUser(User user) {
        return userDao.updateUser (user);
    }

    @Override
    public User getCustomerById(int id) {
        User user=userDao.getUserById (id);
        return user;
    }
}
